$(function () {

});

function searchData() {
    var table = layui.table, layer = layui.layer;

    table.init('serviceTable',{
        data: [
            {
                id:1,
                "SFZH": "44*****************18",
                "HJDZ": "广东省*****路127号",
                "SZXM": "陈**",
                "ZJLM": "身份证",
                "SWSJ": "2018-06-21 00:00:00",
                "TBDWMC": "**卫生院"
            }
        ]
        , toolbar: true
        , title: '死亡人口信息'
        , page: true
    });

    //监听行工具事件
    table.on('tool(serviceTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值

        if (layEvent === 'detail') {
            loadDetail(data.id)
        }
    });
}

function loadDetail(id) {
    var data = [
        {
            id:1,
            "SFZH": "44*****************18",
            "HJDZ": "广东省*****路127号",
            "SZXM": "陈**",
            "ZJLM": "身份证",
            "SWSJ": "2018-06-21 00:00:00",
            "TBDWMC": "**卫生院"
        }
    ];


    var data0 = data[parseInt(id) - 1]
    $('#detailD').html(template('detailDS',{data:data0}));
    layer.open({
        type: 1,
        content: $("#detail"),
        area: ['900px', '550px'],
        title: '死亡人口信息详情',
        maxmin: true,
        shade: 0,
        cancel: function () {
            $("#detail").hide()
        }
    });


}